<script type="text/javascript">
var myChart = new Request.HTML({
	url: 'library/getChart.php',
	method: 'post',
	onSuccess: function(responseText, responseXML) {						
		$('chartContainer').set('text', '');			
		$('chartContainer').adopt(responseText);
		
		$('chartContainer').fade(0, 1);			
	},

	onRequest: function() {	
		$('chartContainer').fade(1, 0);
		$('chartContainer').set('text', '');
	}
});		

var myInsert = new Request.HTML({
	url: 'rencana/<?php echo $subbagian;?>.php',
	method: 'post',
	onSuccess: function(responseText, responseXML) {						
		$('process_rencana').set('text', '');			
		$('process_rencana').adopt(responseText);
		
		$('process_rencana').fade(0, 1);			
	},

	onRequest: function() {	
		$('process_rencana').fade(1, 0);
		$('process_rencana').set('text', '');
	}
});	

var insert = {	
		param: '',
		send: function(form){
			// validasi dulu
			for(var i=0; i<form.elements.length; i++){
				el = form.elements[i];
				
				if(el.type == 'text' && el.value.length < 1){
					alert('Field "'+el.name+'"tidak boleh kosong');
					el.focus();
					return false;
				}
			}
			
			this.param = '';
			for(var i=0; i<form.elements.length; i++){
				el = form.elements[i];
				
				if(el.type == 'text' || el.type == 'hidden'){
					this.param += el.name+'='+el.value+'&';
				}
			}
			
			this.param = this.param + 'subbagian=<?php echo $subbagian;?>'; // tambahkan mode request..
			
			myInsert.send(this.param);
			return false;
		}
}
</script>